package edu.ynu.se.xiecheng.achitectureclass.controller;


import edu.ynu.se.xiecheng.achitectureclass.domain.Result;
import edu.ynu.se.xiecheng.achitectureclass.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * @author zzw
 */

@Api(tags = "登录")
@RestController
@RequestMapping(value = "/api/auth")
@Component
@CrossOrigin
public class UserController {
    @Resource
    private UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }

    @ApiOperation("登录接口")
    @PostMapping(value = "/login")
    public Result login(String username, String password, HttpServletResponse response) {
        return userService.login(response, username, password);
    }
}
